package org.yibinxueyuan.drawcard.service.serivceImpl;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yibinxueyuan.drawcard.service.HandleLogin;
/**
 * 登录事务逻辑实现类
 */
@Service(value = "HandleLoginImpl")
public class HandleLoginImpl implements HandleLogin{

    /**
     * 验证登录
     * @param mailbox
     * @param password
     * @throws AuthenticationException
     */
    public void VerificationLogin(String mailbox, String password)throws AuthenticationException {
        //获取当前用户
        Subject subject = SecurityUtils.getSubject();
        //封装用户的登录数据,保存在令牌中
        UsernamePasswordToken token = new UsernamePasswordToken(mailbox,password);
        //执行登录的方法,如果没有异常就是登录成功
        subject.login(token);
    }



}
